package com.cloudbroker.openapi.mobile.controller;

import static com.cloudbroker.bcs.platform.dav.common.util.RequestUtil.getSingleParameterMapForBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import com.cloudbroker.bcs.platform.dav.bizapi.service.viewpoint.result.*;
import com.cloudbroker.bcs.platform.dav.bizapi.service.viewpoint.vo.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cloudbroker.bcs.common.util.VOUtil;
import com.cloudbroker.bcs.platform.dav.bizapi.service.base.vo.HSBCPSVO;
import com.cloudbroker.bcs.platform.dav.bizapi.service.base.vo.ListQueryVO;
import com.cloudbroker.bcs.platform.dav.bizapi.t2service.viewpoint.BrokerT2BizService;
import com.cloudbroker.bcs.platform.dav.bizapi.t2service.viewpoint.ViewPointT2BizService;
import com.cloudbroker.bcs.platform.dav.common.ext.annotation.SaveLog;

@Controller
public class ViewpointController {
    
    @Resource
    private ViewPointT2BizService viewpointT2;
    
    @Resource
    private BrokerT2BizService brokerT2;

    /**
     * 观点列表
     * */
    @ResponseBody
    @RequestMapping("/func_viewpoint_list_by_fans")
    @SaveLog(remark = "观点列表")
    public ViewpointFansList funcViewpointList(HttpServletRequest request, String jsonpcallback) {
        ViewpointListForm form = getSingleParameterMapForBody(request, ViewpointListForm.class);
        return VOUtil.setJsonpResult(viewpointT2.funcViewpointListByFans(form), jsonpcallback);
    }
    
    /**
     * 观点列表
     * */
    @ResponseBody
    @RequestMapping("/func_viewpoint_list_by_tenant")
    @SaveLog(remark = "观点列表租户级")
    public ViewpointNoLoginList funcViewpointListByTenant(HttpServletRequest request, String jsonpcallback) {
        ListQueryVO form = getSingleParameterMapForBody(request, ViewpointListForm.class);
        return VOUtil.setJsonpResult(viewpointT2.funcViewpointListByTenant(form), jsonpcallback);
    }
    
    /**
     * 未登录获取租户观点列表
     * */
    @ResponseBody
    @RequestMapping("/func_viewpoint_list_by_tenant_nologin")
    @SaveLog(remark = "未登录获取租户观点列表")
    public ViewpointNoLoginList funcViewpointListByTenantNologin(HttpServletRequest request, String jsonpcallback) {
        TenantKeyListQryForm form = getSingleParameterMapForBody(request, TenantKeyListQryForm.class);
        return VOUtil.setJsonpResult(viewpointT2.funcViewpointListByTenantNologin(form), jsonpcallback);
    }
    
    /**
     * 评论详情页面不登录
     * */
    @ResponseBody
    @RequestMapping("/func_comment_view_no_login")
    @SaveLog(remark = "评论详情页面不登录")
    public ViewpointCommentResult funcCommentViewNologin(HttpServletRequest request, String jsonpcallback) {
        ViewpointCommentForm form = getSingleParameterMapForBody(request, ViewpointCommentForm.class);
        return VOUtil.setJsonpResult(viewpointT2.funcCommentViewNologin(form), jsonpcallback);
    }
    
    /**
     * 评论详情页面
     * */
    @ResponseBody
    @RequestMapping("/func_comment_view")
    @SaveLog(remark = "评论详情页面")
    public ViewpointCommentResult funcCommentView(HttpServletRequest request, String jsonpcallback) {
        ViewpointCommentForm form = getSingleParameterMapForBody(request, ViewpointCommentForm.class);
        ViewpointCommentResult result = viewpointT2.funcCommentView(form);
        return VOUtil.setJsonpResult(result, jsonpcallback);
    }
    
    /**
     * 评论
     * */
    @ResponseBody
    @RequestMapping("/func_comment_save")
    @SaveLog(remark = "评论")
    public CommentSaveResult funcComment(HttpServletRequest request, String jsonpcallback) {
        ViewpointCommentSaveForm form = getSingleParameterMapForBody(request, ViewpointCommentSaveForm.class);
        return VOUtil.setJsonpResult(viewpointT2.funcCommentSave(form), jsonpcallback);
    }
    
    /**
     * 查询大V标签
     * */
    @ResponseBody
    @RequestMapping("/func_viewpoint_tag_list")
    @SaveLog(remark = "查询大V标签")
    public ViewpointTagListResult brokerTagList(HttpServletRequest request, String jsonpcallback) {
        HSBCPSVO form = getSingleParameterMapForBody(request, HSBCPSVO.class);
        return VOUtil.setJsonpResult(brokerT2.brokerTagList(form), jsonpcallback);
    }
    
    @ResponseBody
    @RequestMapping("/func_comment_spitslot_upvote")
    @SaveLog(remark = "大V观点评论吐槽和点赞")
    public ViewpointSpitslotUpvoteResult funcCommentSpitslotUpvote(HttpServletRequest request, String jsonpcallback) {
        ViewpointSpitslotUpvoteForm form = getSingleParameterMapForBody(request, ViewpointSpitslotUpvoteForm.class);
        return VOUtil.setJsonpResult(viewpointT2.funcCommentSpitslotUpvote(form), jsonpcallback);
    }
    
    
    @ResponseBody
    @RequestMapping("/func_viewpoint_replay_detail_list")
    @SaveLog(remark = "查看引用详细")
    public ReplyListData funcViewpointReplayDetailList(HttpServletRequest request, String jsonpcallback) {
        ReplyListForm form = getSingleParameterMapForBody(request, ReplyListForm.class);
        return VOUtil.setJsonpResult(viewpointT2.funcViewpointReplayDetailList(form), jsonpcallback);
    }
    
    @ResponseBody
    @RequestMapping("/func_get_viewpoint_content")
    @SaveLog(remark = "获取单个观点内容")
    public ViewpointContentData funcViewpointContent(HttpServletRequest request, String jsonpcallback) {
        ViewPointIdForm form = getSingleParameterMapForBody(request, ViewPointIdForm.class);
        return VOUtil.setJsonpResult(viewpointT2.funcViewpointContent(form), jsonpcallback);
    }

    @ResponseBody
    @RequestMapping("/func_get_dynamic_list")
    @SaveLog(remark = "粉丝端动态推送列表")
    public DynamicListResult funcGetDynamicList(HttpServletRequest request, String jsonpcallback) {
        DynamicListForm form = getSingleParameterMapForBody(request, DynamicListForm.class);
        return VOUtil.setJsonpResult(viewpointT2.funcGetDynamicList(form),jsonpcallback);
    }

    @ResponseBody
    @RequestMapping("/func_realtime_qry_load_more")
    @SaveLog(remark = "粉丝端动态组合的当日成交列表")
    public LTBRealtimeQryResult funcRealtimeQryLoadMore(HttpServletRequest request, String jsonpcallback) {
        LTBRealtimeQryListForm form = getSingleParameterMapForBody(request, LTBRealtimeQryListForm.class);
        return VOUtil.setJsonpResult(viewpointT2.funcRealtimeQryLoadMore(form),jsonpcallback);
    }

}
